package com.liuhe.date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo2 {
    public static void main(String[] args) throws ParseException {
        //默认格式
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        //解析.需要设置好格式
        String str = "2023-03-23 23:14:38";
        Date d2 = sdf.parse(str);
        System.out.println(d2.getTime());

        Date now = new Date(0L);
        String now1 = sdf.format(now);
        System.out.println(now1);
        //年月日
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss EE");
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss EE");
        String now2 = sdf1.format(now);
        System.out.println(now2);



    }
}
